import Taro from '@tarojs/taro';

export default function request(url, options) {

  return new Promise((resolve, reject) => {

    Taro.request({
      url: url,
      header: options.headers,
      method: options.method || 'GET',
      data:
        options.method === 'POST' || options.method === 'PUT' || options.method === 'PATCH' ? options.body : undefined,
      fail: reject,
      success: resolve,
    });
  });
}
